libostree: Add new OstreeSysroot class
authorColin Walters <walters@verbum.org>
Sun, 15 Sep 2013 18:33:57 +0000 (14:33 -0400)
committerColin Walters <walters@verbum.org>
Sun, 15 Sep 2013 18:33:57 +0000 (14:33 -0400)
At the moment, just a container for a path, but we will start moving
admin functionality here.

15 files changed:
Makefile-libostree.am
src/libostree/ostree-sysroot.c [new file with mode: 0644]
src/libostree/ostree-sysroot.h [new file with mode: 0644]
src/libostree/ostree-types.h
src/libostree/ostree.h
src/ostree/ot-admin-builtin-cleanup.c
src/ostree/ot-admin-builtin-deploy.c
src/ostree/ot-admin-builtin-diff.c
src/ostree/ot-admin-builtin-init-fs.c
src/ostree/ot-admin-builtin-os-init.c
src/ostree/ot-admin-builtin-status.c
src/ostree/ot-admin-builtin-undeploy.c
src/ostree/ot-admin-builtin-upgrade.c
src/ostree/ot-admin-builtins.h
src/ostree/ot-builtin-admin.c

index af74b75f871c071580176be76a06d90520340a47..c375527be1a922f327613b8a6a22cf1db1fe2e13 100644 (file)
@@ -43,6 +43,8 @@ libostree_1_la_SOURCES = \
        src/libostree/ostree-repo-file.c \
        src/libostree/ostree-repo-file-enumerator.c \
        src/libostree/ostree-repo-file-enumerator.h \
+       src/libostree/ostree-sysroot.c \
+       src/libostree/ostree-sysroot.h \
        $(NULL)
 if USE_LIBARCHIVE
 libostree_1_la_SOURCES += src/libostree/ostree-libarchive-input-stream.h \
diff --git a/src/libostree/ostree-sysroot.c b/src/libostree/ostree-sysroot.c
new file mode 100644 (file)
index 0000000..4fa27af
--- /dev/null
@@ -0,0 +1,176 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
+ *
+ * Copyright (C) 2013 Colin Walters <walters@verbum.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include "config.h"
+
+#include "otutil.h"
+#include "libgsystem.h"
+
+#include "ostree-sysroot.h"
+
+/**
+ * SECTION:libostree-sysroot
+ * @title: Root partition mount point
+ * @short_description: Manage physical root filesystem
+ *
+ * A #OstreeSysroot object represents a physical root filesystem,
+ * which in particular should contain a toplevel /ostree directory.
+ * Inside this directory is an #OstreeRepo in /ostree/repo, plus a set
+ * of deployments in /ostree/deploy.
+ */
+
+struct OstreeSysroot {
+  GObject parent;
+
+  GFile *path;
+  int sysroot_fd;
+};
+
+typedef struct {
+  GObjectClass parent_class;
+} OstreeSysrootClass;
+
+enum {
+  PROP_0,
+
+  PROP_PATH
+};
+
+G_DEFINE_TYPE (OstreeSysroot, ostree_sysroot, G_TYPE_OBJECT)
+
+static void
+ostree_sysroot_finalize (GObject *object)
+{
+  OstreeSysroot *self = OSTREE_SYSROOT (object);
+
+  g_clear_object (&self->path);
+
+  G_OBJECT_CLASS (ostree_sysroot_parent_class)->finalize (object);
+}
+
+static void
+ostree_sysroot_set_property(GObject         *object,
+                            guint            prop_id,
+                            const GValue    *value,
+                            GParamSpec      *pspec)
+{
+  OstreeSysroot *self = OSTREE_SYSROOT (object);
+
+  switch (prop_id)
+    {
+    case PROP_PATH:
+      /* Canonicalize */
+      self->path = g_file_new_for_path (gs_file_get_path_cached (g_value_get_object (value)));
+      break;
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+    }
+}
+
+static void
+ostree_sysroot_get_property(GObject         *object,
+                            guint            prop_id,
+                            GValue          *value,
+                            GParamSpec      *pspec)
+{
+  OstreeSysroot *self = OSTREE_SYSROOT (object);
+
+  switch (prop_id)
+    {
+    case PROP_PATH:
+      g_value_set_object (value, self->path);
+      break;
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+    }
+}
+
+static void
+ostree_sysroot_constructed (GObject *object)
+{
+  OstreeSysroot *self = OSTREE_SYSROOT (object);
+
+  g_assert (self->path != NULL);
+
+  G_OBJECT_CLASS (ostree_sysroot_parent_class)->constructed (object);
+}
+
+static void
+ostree_sysroot_class_init (OstreeSysrootClass *klass)
+{
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+  object_class->constructed = ostree_sysroot_constructed;
+  object_class->get_property = ostree_sysroot_get_property;
+  object_class->set_property = ostree_sysroot_set_property;
+  object_class->finalize = ostree_sysroot_finalize;
+
+  g_object_class_install_property (object_class,
+                                   PROP_PATH,
+                                   g_param_spec_object ("path",
+                                                        "",
+                                                        "",
+                                                        G_TYPE_FILE,
+                                                        G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+}
+
+static void
+ostree_sysroot_init (OstreeSysroot *self)
+{
+  self->sysroot_fd = -1;
+}
+
+/**
+ * ostree_sysroot_new:
+ * @path: Path to a system root directory
+ *
+ * Returns: (transfer full): An accessor object for an system root located at @path
+ */
+OstreeSysroot*
+ostree_sysroot_new (GFile *path)
+{
+  return g_object_new (OSTREE_TYPE_SYSROOT, "path", path, NULL);
+}
+
+/**
+ * ostree_sysroot_new_default:
+ *
+ * Returns: (transfer full): An accessor for the current visible root / filesystem
+ */
+OstreeSysroot*
+ostree_sysroot_new_default (void)
+{
+  gs_unref_object GFile *rootfs = g_file_new_for_path ("/");
+  return ostree_sysroot_new (rootfs);
+}
+
+/**
+ * ostree_sysroot_get_path:
+ * @self:
+ *
+ * Returns: (transfer none): Path to rootfs
+ */
+GFile *
+ostree_sysroot_get_path (OstreeSysroot  *self)
+{
+  return self->path;
+}
diff --git a/src/libostree/ostree-sysroot.h b/src/libostree/ostree-sysroot.h
new file mode 100644 (file)
index 0000000..b983383
--- /dev/null
@@ -0,0 +1,42 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
+ *
+ * Copyright (C) 2013 Colin Walters <walters@verbum.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#pragma once
+
+#include "ostree-repo.h"
+
+G_BEGIN_DECLS
+
+#define OSTREE_TYPE_SYSROOT ostree_sysroot_get_type()
+#define OSTREE_SYSROOT(obj) \
+  (G_TYPE_CHECK_INSTANCE_CAST ((obj), OSTREE_TYPE_SYSROOT, OstreeSysroot))
+#define OSTREE_IS_SYSROOT(obj) \
+  (G_TYPE_CHECK_INSTANCE_TYPE ((obj), OSTREE_TYPE_SYSROOT))
+
+GType ostree_sysroot_get_type (void);
+
+OstreeSysroot* ostree_sysroot_new (GFile *path);
+
+OstreeSysroot* ostree_sysroot_new_default (void);
+
+GFile *ostree_sysroot_get_path (OstreeSysroot *self);
+
+G_END_DECLS
+
index a0fff03d95ccafd0c2eac2be6f774fbcb17a4695..b15cbbc96fc46c023ef5ecc219cb4993bc9b9dda 100644 (file)
@@ -27,6 +27,7 @@
 G_BEGIN_DECLS
 
 typedef struct OstreeRepo OstreeRepo;
+typedef struct OstreeSysroot OstreeSysroot;
 typedef struct OstreeMutableTree OstreeMutableTree;
 typedef struct OstreeRepoFile OstreeRepoFile;
 
index efafe0d36cb9f0630b276b509e28ce95f78a53a9..aaaeb1b459a09413f43069676d1e48cb6b97c82b 100644 (file)
@@ -26,4 +26,5 @@
 #include <ostree-repo.h>
 #include <ostree-mutable-tree.h>
 #include <ostree-repo-file.h>
+#include <ostree-sysroot.h>
 #include <ostree-diff.h>
index 8b08ed28ea80cee2751d6a73303348f070db7648..929bf39efe8db072e6f19f76a38783ec30d6926b 100644 (file)
@@ -34,7 +34,7 @@ static GOptionEntry options[] = {
 };
 
 gboolean
-ot_admin_builtin_cleanup (int argc, char **argv, GFile *sysroot, GCancellable *cancellable, GError **error)
+ot_admin_builtin_cleanup (int argc, char **argv, OstreeSysroot *sysroot, GCancellable *cancellable, GError **error)
 {
   GOptionContext *context;
   gboolean ret = FALSE;
@@ -46,7 +46,7 @@ ot_admin_builtin_cleanup (int argc, char **argv, GFile *sysroot, GCancellable *c
   if (!g_option_context_parse (context, &argc, &argv, error))
     goto out;
 
-  if (!ot_admin_cleanup (sysroot, cancellable, error))
+  if (!ot_admin_cleanup (ostree_sysroot_get_path (sysroot), cancellable, error))
     goto out;
 
   ret = TRUE;
index 6652f56aac863e476edfb743593054a8bb1568d3..7f49e4f5c8345f8b8bb3183859cbb8fcb3b94e5f 100644 (file)
@@ -47,7 +47,7 @@ static GOptionEntry options[] = {
 };
 
 gboolean
-ot_admin_builtin_deploy (int argc, char **argv, GFile *sysroot, GCancellable *cancellable, GError **error)
+ot_admin_builtin_deploy (int argc, char **argv, OstreeSysroot *sysroot, GCancellable *cancellable, GError **error)
 {
   gboolean ret = FALSE;
   const char *refspec;
@@ -77,10 +77,10 @@ ot_admin_builtin_deploy (int argc, char **argv, GFile *sysroot, GCancellable *ca
 
   refspec = argv[1];
 
-  if (!ot_admin_get_repo (sysroot, &repo, cancellable, error))
+  if (!ot_admin_get_repo (ostree_sysroot_get_path (sysroot), &repo, cancellable, error))
     goto out;
 
-  if (!ot_admin_list_deployments (sysroot, &current_bootversion, &current_deployments,
+  if (!ot_admin_list_deployments (ostree_sysroot_get_path (sysroot), &current_bootversion, &current_deployments,
                                   cancellable, error))
     {
       g_prefix_error (error, "While listing deployments: ");
@@ -90,7 +90,7 @@ ot_admin_builtin_deploy (int argc, char **argv, GFile *sysroot, GCancellable *ca
   /* Find the currently booted deployment, if any; we will ensure it
    * is present in the new deployment list.
    */
-  if (!ot_admin_require_deployment_or_osname (sysroot, current_deployments,
+  if (!ot_admin_require_deployment_or_osname (ostree_sysroot_get_path (sysroot), current_deployments,
                                               opt_osname,
                                               &booted_deployment,
                                               cancellable, error))
@@ -114,7 +114,7 @@ ot_admin_builtin_deploy (int argc, char **argv, GFile *sysroot, GCancellable *ca
   if (!ostree_repo_resolve_rev (repo, refspec, FALSE, &revision, error))
     goto out;
 
-  if (!ot_admin_deploy (sysroot, current_bootversion, current_deployments,
+  if (!ot_admin_deploy (ostree_sysroot_get_path (sysroot), current_bootversion, current_deployments,
                         opt_osname, revision, origin,
                         opt_kernel_argv, opt_retain,
                         booted_deployment, NULL,
index 1758422e71742f93eb9bd33007f55cafa09ab28a..e64fe7ea45f9202b518af36a6f5d6a03c9ec7f6c 100644 (file)
@@ -37,7 +37,7 @@ static GOptionEntry options[] = {
 };
 
 gboolean
-ot_admin_builtin_diff (int argc, char **argv, GFile *sysroot, GCancellable *cancellable, GError **error)
+ot_admin_builtin_diff (int argc, char **argv, OstreeSysroot *sysroot, GCancellable *cancellable, GError **error)
 {
   GOptionContext *context;
   gboolean ret = FALSE;
@@ -59,16 +59,16 @@ ot_admin_builtin_diff (int argc, char **argv, GFile *sysroot, GCancellable *canc
   if (!g_option_context_parse (context, &argc, &argv, error))
     goto out;
   
-  repo_path = g_file_resolve_relative_path (sysroot, "ostree/repo");
+  repo_path = g_file_resolve_relative_path (ostree_sysroot_get_path (sysroot), "ostree/repo");
 
-  if (!ot_admin_list_deployments (sysroot, &bootversion, &deployments,
+  if (!ot_admin_list_deployments (ostree_sysroot_get_path (sysroot), &bootversion, &deployments,
                                   cancellable, error))
     {
       g_prefix_error (error, "While listing deployments: ");
       goto out;
     }
 
-  if (!ot_admin_require_deployment_or_osname (sysroot, deployments,
+  if (!ot_admin_require_deployment_or_osname (ostree_sysroot_get_path (sysroot), deployments,
                                               opt_osname, &deployment,
                                               cancellable, error))
     goto out;
@@ -83,7 +83,7 @@ ot_admin_builtin_diff (int argc, char **argv, GFile *sysroot, GCancellable *canc
       goto out;
     }
 
-  deployment_dir = ot_admin_get_deployment_directory (sysroot, deployment);
+  deployment_dir = ot_admin_get_deployment_directory (ostree_sysroot_get_path (sysroot), deployment);
 
   orig_etc_path = g_file_resolve_relative_path (deployment_dir, "usr/etc");
   new_etc_path = g_file_resolve_relative_path (deployment_dir, "etc");
index dbfd0ba7cf7d9f44ef6e83ccfdf374f5ec0f1d5c..78872b77160c7e5d388d470725db6f7076ebfbf2 100644 (file)
@@ -34,7 +34,7 @@ static GOptionEntry options[] = {
 };
 
 gboolean
-ot_admin_builtin_init_fs (int argc, char **argv, GFile *sysroot, GCancellable *cancellable, GError **error)
+ot_admin_builtin_init_fs (int argc, char **argv, OstreeSysroot *sysroot, GCancellable *cancellable, GError **error)
 {
   GOptionContext *context;
   gboolean ret = FALSE;
index b9e8570975d99ec88c917a8437bd177882395a49..414662a4ec951a915944cb5511e069c4b9b598f1 100644 (file)
@@ -34,7 +34,7 @@ static GOptionEntry options[] = {
 };
 
 gboolean
-ot_admin_builtin_os_init (int argc, char **argv, GFile *sysroot, GCancellable *cancellable, GError **error)
+ot_admin_builtin_os_init (int argc, char **argv, OstreeSysroot *sysroot, GCancellable *cancellable, GError **error)
 {
   GOptionContext *context;
   gboolean ret = FALSE;
@@ -48,7 +48,7 @@ ot_admin_builtin_os_init (int argc, char **argv, GFile *sysroot, GCancellable *c
   if (!g_option_context_parse (context, &argc, &argv, error))
     goto out;
 
-  if (!ot_admin_ensure_initialized (sysroot, cancellable, error))
+  if (!ot_admin_ensure_initialized (ostree_sysroot_get_path (sysroot), cancellable, error))
     goto out;
 
   if (argc < 2)
@@ -59,7 +59,7 @@ ot_admin_builtin_os_init (int argc, char **argv, GFile *sysroot, GCancellable *c
 
   osname = argv[1];
 
-  deploy_dir = ot_gfile_get_child_build_path (sysroot, "ostree", "deploy", osname, NULL);
+  deploy_dir = ot_gfile_get_child_build_path (ostree_sysroot_get_path (sysroot), "ostree", "deploy", osname, NULL);
 
   /* Ensure core subdirectories of /var exist, since we need them for
    * dracut generation, and the host will want them too.  Note that at
index eb5b7659313958c8d3f76bdcdedc1a791a633533..f29fd8bfbb6da84d61dc1586f39fc110aa901b12 100644 (file)
@@ -34,7 +34,7 @@ static GOptionEntry options[] = {
 };
 
 gboolean
-ot_admin_builtin_status (int argc, char **argv, GFile *sysroot, GCancellable *cancellable, GError **error)
+ot_admin_builtin_status (int argc, char **argv, OstreeSysroot *sysroot, GCancellable *cancellable, GError **error)
 {
   GOptionContext *context;
   gboolean ret = FALSE;
@@ -50,14 +50,14 @@ ot_admin_builtin_status (int argc, char **argv, GFile *sysroot, GCancellable *ca
   if (!g_option_context_parse (context, &argc, &argv, error))
     goto out;
 
-  if (!ot_admin_list_deployments (sysroot, &bootversion, &deployments,
+  if (!ot_admin_list_deployments (ostree_sysroot_get_path (sysroot), &bootversion, &deployments,
                                   cancellable, error))
     {
       g_prefix_error (error, "While listing deployments: ");
       goto out;
     }
 
-  if (!ot_admin_find_booted_deployment (sysroot, deployments,
+  if (!ot_admin_find_booted_deployment (ostree_sysroot_get_path (sysroot), deployments,
                                         &booted_deployment,
                                         cancellable, error))
     goto out;
@@ -70,7 +70,7 @@ ot_admin_builtin_status (int argc, char **argv, GFile *sysroot, GCancellable *ca
     {
       int subbootversion;
 
-      if (!ot_admin_read_current_subbootversion (sysroot, bootversion,
+      if (!ot_admin_read_current_subbootversion (ostree_sysroot_get_path (sysroot), bootversion,
                                                  &subbootversion,
                                                  cancellable, error))
         goto out;
index 0386bba149965ee9ba1124b66087591dab2250fe..5a6a279341dbb3c861d69af7f72396427c54cb55 100644 (file)
@@ -34,7 +34,7 @@ static GOptionEntry options[] = {
 };
 
 gboolean
-ot_admin_builtin_undeploy (int argc, char **argv, GFile *sysroot, GCancellable *cancellable, GError **error)
+ot_admin_builtin_undeploy (int argc, char **argv, OstreeSysroot *sysroot, GCancellable *cancellable, GError **error)
 {
   gboolean ret = FALSE;
   GOptionContext *context;
@@ -61,14 +61,14 @@ ot_admin_builtin_undeploy (int argc, char **argv, GFile *sysroot, GCancellable *
   deploy_index_str = argv[1];
   deploy_index = atoi (deploy_index_str);
 
-  if (!ot_admin_list_deployments (sysroot, &current_bootversion, &current_deployments,
+  if (!ot_admin_list_deployments (ostree_sysroot_get_path (sysroot), &current_bootversion, &current_deployments,
                                   cancellable, error))
     {
       g_prefix_error (error, "While listing deployments: ");
       goto out;
     }
 
-  if (!ot_admin_find_booted_deployment (sysroot, current_deployments, &booted_deployment,
+  if (!ot_admin_find_booted_deployment (ostree_sysroot_get_path (sysroot), current_deployments, &booted_deployment,
                                         cancellable, error))
     goto out;
 
@@ -95,7 +95,7 @@ ot_admin_builtin_undeploy (int argc, char **argv, GFile *sysroot, GCancellable *
   
   g_ptr_array_remove_index (current_deployments, deploy_index);
 
-  if (!ot_admin_write_deployments (sysroot, current_bootversion,
+  if (!ot_admin_write_deployments (ostree_sysroot_get_path (sysroot), current_bootversion,
                                    current_bootversion ? 0 : 1, current_deployments,
                                    cancellable, error))
     goto out;
@@ -103,7 +103,7 @@ ot_admin_builtin_undeploy (int argc, char **argv, GFile *sysroot, GCancellable *
   g_print ("Deleted deployment %s.%d\n", ot_deployment_get_csum (target_deployment),
            ot_deployment_get_deployserial (target_deployment));
   
-  if (!ot_admin_cleanup (sysroot, cancellable, error))
+  if (!ot_admin_cleanup (ostree_sysroot_get_path (sysroot), cancellable, error))
     {
       g_prefix_error (error, "Performing final cleanup: ");
       goto out;
index 882c41aa263761ad097f1bf2faf3f1acddf44e75..269bcdd6a0aa49a209e1db82805cfdaac45ad445 100644 (file)
@@ -43,7 +43,7 @@ static GOptionEntry options[] = {
 };
 
 gboolean
-ot_admin_builtin_upgrade (int argc, char **argv, GFile *sysroot, GCancellable *cancellable, GError **error)
+ot_admin_builtin_upgrade (int argc, char **argv, OstreeSysroot *sysroot, GCancellable *cancellable, GError **error)
 {
   gboolean ret = FALSE;
   GOptionContext *context;
@@ -70,7 +70,7 @@ ot_admin_builtin_upgrade (int argc, char **argv, GFile *sysroot, GCancellable *c
   if (!g_option_context_parse (context, &argc, &argv, error))
     goto out;
 
-  if (!ot_admin_list_deployments (sysroot, &current_bootversion,
+  if (!ot_admin_list_deployments (ostree_sysroot_get_path (sysroot), &current_bootversion,
                                   &current_deployments,
                                   cancellable, error))
     {
@@ -78,7 +78,7 @@ ot_admin_builtin_upgrade (int argc, char **argv, GFile *sysroot, GCancellable *c
       goto out;
     }
 
-  if (!ot_admin_require_deployment_or_osname (sysroot, current_deployments,
+  if (!ot_admin_require_deployment_or_osname (ostree_sysroot_get_path (sysroot), current_deployments,
                                               opt_osname,
                                               &booted_deployment,
                                               cancellable, error))
@@ -88,10 +88,10 @@ ot_admin_builtin_upgrade (int argc, char **argv, GFile *sysroot, GCancellable *c
   merge_deployment = ot_admin_get_merge_deployment (current_deployments, opt_osname,
                                                     booted_deployment);
 
-  deployment_path = ot_admin_get_deployment_directory (sysroot, merge_deployment);
+  deployment_path = ot_admin_get_deployment_directory (ostree_sysroot_get_path (sysroot), merge_deployment);
   deployment_origin_path = ot_admin_get_deployment_origin_path (deployment_path);
 
-  repo_path = g_file_resolve_relative_path (sysroot, "ostree/repo");
+  repo_path = g_file_resolve_relative_path (ostree_sysroot_get_path (sysroot), "ostree/repo");
   repo = ostree_repo_new (repo_path);
   if (!ostree_repo_open (repo, cancellable, error))
     goto out;
@@ -135,7 +135,7 @@ ot_admin_builtin_upgrade (int argc, char **argv, GFile *sysroot, GCancellable *c
   else
     {
       gs_unref_object GFile *real_sysroot = g_file_new_for_path ("/");
-      if (!ot_admin_deploy (sysroot,
+      if (!ot_admin_deploy (ostree_sysroot_get_path (sysroot),
                             current_bootversion, current_deployments,
                             opt_osname, new_revision, origin,
                             NULL, FALSE,
@@ -144,7 +144,7 @@ ot_admin_builtin_upgrade (int argc, char **argv, GFile *sysroot, GCancellable *c
                             cancellable, error))
         goto out;
 
-      if (opt_reboot && g_file_equal (sysroot, real_sysroot))
+      if (opt_reboot && g_file_equal (ostree_sysroot_get_path (sysroot), real_sysroot))
         {
           gs_subprocess_simple_run_sync (NULL, GS_SUBPROCESS_STREAM_DISPOSITION_INHERIT,
                                          cancellable, error,
index bc7b8fc40defdf962f98bdbcc5ad1cafa69ef41b..eaea2af466d04ff3e39edf74c43cf051b3484d69 100644 (file)
 
 #pragma once
 
-#include <gio/gio.h>
+#include <ostree.h>
 
 G_BEGIN_DECLS
 
-gboolean ot_admin_builtin_os_init (int argc, char **argv, GFile *sysroot, GCancellable *cancellable, GError **error);
-gboolean ot_admin_builtin_install (int argc, char **argv, GFile *sysroot, GCancellable *cancellable, GError **error);
-gboolean ot_admin_builtin_init_fs (int argc, char **argv, GFile *sysroot, GCancellable *cancellable, GError **error);
-gboolean ot_admin_builtin_undeploy (int argc, char **argv, GFile *sysroot, GCancellable *cancellable, GError **error);
-gboolean ot_admin_builtin_deploy (int argc, char **argv, GFile *sysroot, GCancellable *cancellable, GError **error);
-gboolean ot_admin_builtin_cleanup (int argc, char **argv, GFile *sysroot, GCancellable *cancellable, GError **error);
-gboolean ot_admin_builtin_status (int argc, char **argv, GFile *sysroot, GCancellable *cancellable, GError **error);
-gboolean ot_admin_builtin_diff (int argc, char **argv, GFile *sysroot, GCancellable *cancellable, GError **error);
-gboolean ot_admin_builtin_upgrade (int argc, char **argv, GFile *sysroot, GCancellable *cancellable, GError **error);
+gboolean ot_admin_builtin_os_init (int argc, char **argv, OstreeSysroot *sysroot, GCancellable *cancellable, GError **error);
+gboolean ot_admin_builtin_install (int argc, char **argv, OstreeSysroot *sysroot, GCancellable *cancellable, GError **error);
+gboolean ot_admin_builtin_init_fs (int argc, char **argv, OstreeSysroot *sysroot, GCancellable *cancellable, GError **error);
+gboolean ot_admin_builtin_undeploy (int argc, char **argv, OstreeSysroot *sysroot, GCancellable *cancellable, GError **error);
+gboolean ot_admin_builtin_deploy (int argc, char **argv, OstreeSysroot *sysroot, GCancellable *cancellable, GError **error);
+gboolean ot_admin_builtin_cleanup (int argc, char **argv, OstreeSysroot *sysroot, GCancellable *cancellable, GError **error);
+gboolean ot_admin_builtin_status (int argc, char **argv, OstreeSysroot *sysroot, GCancellable *cancellable, GError **error);
+gboolean ot_admin_builtin_diff (int argc, char **argv, OstreeSysroot *sysroot, GCancellable *cancellable, GError **error);
+gboolean ot_admin_builtin_upgrade (int argc, char **argv, OstreeSysroot *sysroot, GCancellable *cancellable, GError **error);
 
 G_END_DECLS
 
index e6ea3e9d0e0acf03a2f2e822ed8cefea9d98fa0f..93d2efa74923b5e4ad7475c435ffa86c57dc55ab 100644 (file)
@@ -34,7 +34,7 @@
 
 typedef struct {
   const char *name;
-  gboolean (*fn) (int argc, char **argv, GFile *sysroot, GCancellable *cancellable, GError **error);
+  gboolean (*fn) (int argc, char **argv, OstreeSysroot *sysroot, GCancellable *cancellable, GError **error);
 } OstreeAdminCommand;
 
 static OstreeAdminCommand admin_subcommands[] = {
@@ -56,7 +56,8 @@ ostree_builtin_admin (int argc, char **argv, OstreeRepo *repo, GCancellable *can
   const char *opt_sysroot = "/";
   const char *subcommand_name = NULL;
   OstreeAdminCommand *subcommand;
-  gs_unref_object GFile *sysroot = NULL;
+  gs_unref_object GFile *sysroot_path = NULL;
+  gs_unref_object OstreeSysroot *sysroot = NULL;
   gboolean want_help = FALSE;
   int in, out, i;
   gboolean skip;
@@ -170,7 +171,8 @@ ostree_builtin_admin (int argc, char **argv, OstreeRepo *repo, GCancellable *can
       goto out;
     }
 
-  sysroot = g_file_new_for_path (opt_sysroot);
+  sysroot_path = g_file_new_for_path (opt_sysroot);
+  sysroot = ostree_sysroot_new (sysroot_path);
   if (!subcommand->fn (argc, argv, sysroot, cancellable, error))
     goto out;